package edu.fdzc.system.service.impl;

import cn.hutool.core.date.DateUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import edu.fdzc.system.entity.ExamPlan;
import edu.fdzc.system.mapper.ExamPlanMapper;
import edu.fdzc.system.service.ExamPlanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ExamPlanServiceImpl implements ExamPlanService {

    @Autowired
    private ExamPlanMapper examPlanMapper;

    @Override
    public void add(ExamPlan examPlan) {
        examPlan.setTime(DateUtil.now());
        examPlanMapper.add(examPlan);
    }

    @Override
    public void updateById(ExamPlan examPlan) {
        examPlanMapper.updateById(examPlan);
    }

    @Override
    public void deleteById(Integer id) {
        examPlanMapper.deleteById(id);
    }

    @Override
    public void deleteByIds(List<Integer> ids) {
        for(Integer id:ids){
            examPlanMapper.deleteById(id);
        }
    }

    @Override
    public ExamPlan selectById(Integer id) {
        return examPlanMapper.selectById(id);

    }

    @Override
    public List<ExamPlan> selectAll(ExamPlan examPlan) {
        return examPlanMapper.selectAll(examPlan);
    }

    @Override
    public PageInfo<ExamPlan> selectPage(ExamPlan examPlan, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<ExamPlan> list = examPlanMapper.selectAll(examPlan);
        return PageInfo.of(list);
    }
}
